<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>订单管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
				suo();	
		});
		$(function(){
			$("#btnImportSubmit").click(function(){
				$("#searchForm").attr("action","${ctx}/sys/orders/export")
				$("#searchForm").submit();
			})
			
			$("#btnSubmit").click(function(){
				$("#searchForm").attr("action","${ctx}/sys/orders")
				$("#searchForm").submit();
			})
		})
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		 function suo(){
			var type=$("#type").val();
			var buyStore=$("#stors").val();
			
			$.ajax({
		        type : "post",
		        async : false,
		        url : "${ctx}/sys/yongUser/storeList",
		        data : {
		            'type' : type
		        },
		        dataType : "json",
		        success : function(msg) {
		            $("#buyStoreCode").empty();
		            
		             $('#buyStoreCode').append('<option selected="selected" value="">所属门店</option>')
		             
		            //$("#template").select2();
		            if (msg.length > 0) {
		                for (var i = 0; i < msg.length; i++) {
		                        var partId = msg[i].code;
		                        var partName = msg[i].cnName;
		                         
		                        if(buyStore==partId){
		             		       
			                    	   var $option = $("<option selected='selected'>").attr({
				                            "value" : partId
				                        }).text(partName);
			                    }else{
		       
		                        var $option = $("<option>").attr({
		                            "value" : partId
		                        }).text(partName);
		                        
			                    }
		                        $("#buyStoreCode").append($option);
		                }
		                $("#buyStoreCode").change();

		            }
		        },
		        error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
		    });
		} 
		 
		 function wuLiu(v){
				window.location.href="${ctx}/sys/orders/wuInformatin?orderCode="+v;
			 
		 }
	</script>
</head>
<body>
    <input value="${orders.buyStoreCode }" id="stors" type="hidden"/>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/orders/">全部订单</a></li>
		<%-- <shiro:hasPermission name="sys:orders:edit"><li><a href="${ctx}/sys/orders/form">订单管理添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="orders" action="${ctx}/sys/orders/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
		
		    <li><label>订单编号：</label>
				<form:input path="code" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			
			<li><label>下单用户类型：</label>
				<form:select id="userType" path="userType" class="input-medium">
			    <form:option value="" label="请选择用户类型"/>
			    <form:options items="${fns:getDictList('user_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			 <li><label>下单时间：</label>
				<input name="startTime" type="text" readonly="readonly" placeholder="开始时间" class="input-medium Wdate " 
					value="<fmt:formatDate value="${order.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			         onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			     &nbsp;&nbsp;&nbsp;&nbsp;
			     <input name="endTime" type="text" readonly="readonly" placeholder="结束时间" class="input-medium Wdate " 
					value="<fmt:formatDate  value="${order.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			     onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
			</li> 
		    <li><label>下单门店类型：</label>
		        <form:select id="type" path="type" class="input-medium" onchange="suo()">
				<form:option value="" label="请选择门店类型"/>
			    <form:options items="${fns:getDictList('store_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			<li>
			<li><label>下单门店：</label><form:select id="buyStoreCode" path="buyStoreCode" class="input-medium">
			<%-- <form:option value="" label="下单门店"/> --%>
			<%-- <form:options items="${store}" htmlEscape="false" itemValue="code" itemLabel="cnName"/> --%>
			</form:select>
			</li>
			<li class="btns"><input id='btnImportSubmit' class="btn btn-primary btnImportSubmit" type="button" value="导出  " />  </li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>订单编号</th>
				<th>下单时间</th>
				<th>用户类型</th>
				<th>下单用户</th>
				<th>所属门店</th>
				<th>所属业务员</th>
				<th>订单金额</th>
				<th>下单门店</th>
				<th>下单业务员</th>
				<th>状态</th>
				<shiro:hasPermission name="sys:orders:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="orders" varStatus="status">
			<tr>
			    <td>${status.index+1}</td>
			    <td><a href="${ctx}/sys/orders/form?id=${orders.id}&tagUrl=${ctx}/sys/orders&tagName=0">${orders.code }</a></td>
				<td>
					<fmt:formatDate value="${orders.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>${fns:getDictLabel(orders.userType, 'user_type', '')}</td>
				<td>
				  <c:if test="${orders.userType==1 }">
				  ${orders.userName }
				  </c:if>
				   <c:if test="${orders.userType==2 }">
				  ${orders.company }
				  </c:if>
				</td>
				<td>${orders.suoStore}</td>
				<td>${orders.suoYe }</td>
				<td>${orders.payMoney }</td>
				<td>${orders.buyStoreName }</td>
				<td>${orders.xiaYeUser }</td>
				<td>
				${fns:getDictLabel(orders.state, 'orders_state', '')}
				</td>
			
				<shiro:hasPermission name="sys:orders:edit"><td>
    				<c:if test="${orders.state==4 or orders.state==3 or orders.state==5 or orders.state==7 or orders.state==8 }">
    				<a href="javascript:void(0);" onclick ="wuLiu(${orders.code})">物流追踪</a>
    				</c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>